import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:yuanquan/widgets/PandaSwitch.dart';

// class SwitchServerDialog extends StatelessWidget {
//   @override
//   Widget build(BuildContext context) {
//     return 
//   }

// }

class SwitchServerDialog extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _SwitchServerDialogState();
  
}

class _SwitchServerDialogState extends State<SwitchServerDialog> {
  var state1 = true;//
  var state2 = true;//
  
  @override
  Widget build(BuildContext context) {
    return switchServerDialog(context);
  }

  Widget switchServerDialog(BuildContext context) {
    return Dialog(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(8),
      ),
      child: Container(
        // height: 200,
        child: Padding(padding:EdgeInsets.all(16),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              // 添加标题
              Center(child: Text('服务器地址', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),),
              SizedBox(height: 8,),
              // 添加内容
              // Text('服务器地址:'),
              TextField(
                decoration: InputDecoration(
                  labelText: state1? "https://app.feparks.com" : "https://test.feparks.com",
                  border: InputBorder.none, 
                  hintText: "服务器地址", 
                  hintStyle: TextStyle(color: Color.fromARGB(255, 219, 221, 223)),
                ), 
              ),
              // Text('园付通地址:'),
              TextField(
                decoration: InputDecoration(
                  labelText: state1? "https://app.feparks.com" : "https://test.feparks.com",
                  border: InputBorder.none, 
                  hintText: "园付通地址", 
                  hintStyle: TextStyle(color: Color.fromARGB(255, 219, 221, 223)),
                ), 
              ),
              SizedBox(height: 16,),
              Row(children: [
                Text("正式"),
                SizedBox(width: 8,),
                PandaSwitch(value: state1, onChanged: (p0) {
                  // Fluttertoast.showToast(msg: "switch=$p0");
                  setState(() {
                    state1 = !state1;
                  });
                },),
                SizedBox(width: 60,),
                Text("禁用主私服"),
                SizedBox(width: 8,),
                PandaSwitch(value: state2, onChanged: (p0) {
                  // Fluttertoast.showToast(msg: "switch=$p0");
                  setState(() {
                    state2 = !state2;
                  });
                },),
              ],),
              SizedBox(height: 16,),
              // 添加按钮
              Center(child: ElevatedButton(
                child: Text('确定'),
                onPressed: () {
                  Navigator.of(context).pop();
                  Fluttertoast.showToast(msg: "设置成功");
                },
              ),),
            ],
          ),
        )
      ),
    );
  }
  
}

